home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
mint
/
mint104s.zoo
/
mint.src
/
biosfs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-08
|
34KB
|
1,486 lines
/*
Copyright 1991,1992 Eric R. Smith. All rights reserved.
*/
/* simple biosfs.c */
#include "mint.h"
extern struct kerinfo kernelinfo; /* see main.c */
static long ARGS_ON_STACK bios_root P_((int drv, fcookie *fc));
static long ARGS_ON_STACK bios_lookup P_((fcookie *dir, const char *name, fcookie *fc));
static long ARGS_ON_STACK bios_getxattr P_((fcookie *fc, XATTR *xattr));
static long ARGS_ON_STACK bios_chattr P_((fcookie *fc, int attrib));
static long ARGS_ON_STACK bios_chown P_((fcookie *fc, int uid, int gid));
static long ARGS_ON_STACK bios_chmode P_((fcookie *fc, unsigned mode));
static long ARGS_ON_STACK bios_rmdir P_((fcookie *dir, const char *name));
static long ARGS_ON_STACK bios_remove P_((fcookie *dir, const char *name));
static long ARGS_ON_STACK bios_getname P_((fcookie *root, fcookie *dir, char *pathname, int size));
static long ARGS_ON_STACK bios_rename P_((fcookie *olddir, char *oldname,
fcookie *newdir, const char *newname));
static long ARGS_ON_STACK bios_opendir P_((DIR *dirh, int flags));
static long ARGS_ON_STACK bios_readdir P_((DIR *dirh, char *nm, int nmlen, fcookie *fc));
static long ARGS_ON_STACK bios_rewinddir P_((DIR *dirh));
static long ARGS_ON_STACK bios_closedir P_((DIR *dirh));
static long ARGS_ON_STACK bios_pathconf P_((fcookie *dir, int which));
static long ARGS_ON_STACK bios_dfree P_((fcookie *dir, long *buf));
static DEVDRV * ARGS_ON_STACK bios_getdev P_((fcookie *fc, long *devspecial));
static long ARGS_ON_STACK bios_fscntl P_((fcookie *, const char *, int, long));
static long ARGS_ON_STACK bios_symlink P_((fcookie *, const char *, const char *));
static long ARGS_ON_STACK bios_readlink P_((fcookie *, char *, int));
static long ARGS_ON_STACK bios_topen P_((FILEPTR *f));
static long ARGS_ON_STACK bios_twrite P_((FILEPTR *f, const char *buf, long bytes));
static long ARGS_ON_STACK bios_tread P_((FILEPTR *f, char *buf, long bytes));
static long ARGS_ON_STACK bios_nwrite P_((FILEPTR *f, const char *buf, long bytes));
static long ARGS_ON_STACK bios_nread P_((FILEPTR *f, char *buf, long bytes));
static long ARGS_ON_STACK bios_ioctl P_((FILEPTR *f, int mode, void *buf));
static long ARGS_ON_STACK bios_select P_((FILEPTR *f, long p, int mode));
static void ARGS_ON_STACK bios_unselect P_((FILEPTR *f, long p, int mode));
static long ARGS_ON_STACK bios_tseek P_((FILEPTR *f, long where, int whence));
long ARGS_ON_STACK null_open P_((FILEPTR *f));
long ARGS_ON_STACK null_write P_((FILEPTR *f, const char *buf, long bytes));
long ARGS_ON_STACK null_read P_((FILEPTR *f, char *buf, long bytes));
long ARGS_ON_STACK null_lseek P_((FILEPTR *f, long where, int whence));
long ARGS_ON_STACK null_ioctl P_((FILEPTR *f, int mode, void *buf));
long ARGS_ON_STACK null_datime P_((FILEPTR *f, short *time, int rwflag));
long ARGS_ON_STACK null_close P_((FILEPTR *f, int pid));
long ARGS_ON_STACK null_select P_((FILEPTR *f, long p, int mode));
void ARGS_ON_STACK null_unselect P_((FILEPTR *f, long p, int mode));
static long ARGS_ON_STACK mouse_open P_((FILEPTR *f));
static long ARGS_ON_STACK mouse_read P_((FILEPTR *f, char *buf, long nbytes));
static long ARGS_ON_STACK mouse_ioctl P_((FILEPTR *f, int mode, void *buf));
static long ARGS_ON_STACK mouse_close P_((FILEPTR *f, int pid));
static long ARGS_ON_STACK mouse_select P_((FILEPTR *f, long p, int mode));
static void ARGS_ON_STACK mouse_unselect P_((FILEPTR *f, long p, int mode));
/* device driver for BIOS terminals */
DEVDRV bios_tdevice = {
bios_topen, bios_twrite, bios_tread, bios_tseek, bios_ioctl,
null_datime, null_close, bios_select, bios_unselect
};
/* device driver for BIOS devices that are not terminals */
DEVDRV bios_ndevice = {
null_open, bios_nwrite, bios_nread, null_lseek, bios_ioctl,
null_datime, null_close, bios_select, bios_unselect
};
DEVDRV null_device = {
null_open, null_write, null_read, null_lseek, null_ioctl,
null_datime, null_close, null_select, null_unselect
};
DEVDRV mouse_device = {
mouse_open, null_write, mouse_read, null_lseek, mouse_ioctl,
null_datime, mouse_close, mouse_select, mouse_unselect
};
/* this special driver is checked for in dosfile.c, and indicates that
* a dup operation is actually wanted rather than an open
*/
DEVDRV fakedev;
#ifdef FASTTEXT
extern DEVDRV screen_device; /* see fasttext.c */
#endif
FILESYS bios_filesys = {
(FILESYS *)0,
FS_LONGPATH,
bios_root,
bios_lookup, nocreat, bios_getdev, bios_getxattr,
bios_chattr, bios_chown, bios_chmode,
nomkdir, bios_rmdir, bios_remove, bios_getname, bios_rename,
bios_opendir, bios_readdir, bios_rewinddir, bios_closedir,
bios_pathconf, bios_dfree, nowritelabel, noreadlabel,
bios_symlink, bios_readlink, nohardlink, bios_fscntl, nodskchng
};
struct tty con_tty, aux_tty, midi_tty;
struct tty sccb_tty, scca_tty, ttmfp_tty;
#define BNAME_MAX 13
struct bios_file {
char name[BNAME_MAX+1]; /* device name */
DEVDRV *device; /* device driver for device */
short private; /* extra info for device driver */
ushort flags; /* flags for device open */
struct tty *tty; /* tty structure (if appropriate) */
struct bios_file *next;
};
struct bios_file BDEV[] = {
/* "real" bios devices present on all machines */
{"centr", &bios_ndevice, 0, 0, 0, 0},
{"console", &bios_tdevice, 2, O_TTY, &con_tty, 0},
{"midi", &bios_tdevice, 3, O_TTY, &midi_tty, 0},
{"kbd", &bios_ndevice, 4, 0, 0, 0},
/* devices that duplicate handles */
{"prn", &fakedev, -3, 0, 0, 0}, /* handle -3 (printer) */
{"aux", &fakedev, -2, 0, 0, 0}, /* handle -2 (aux. terminal) */
{"con", &fakedev, -1, 0, 0, 0}, /* handle -1 (control terminal) */
{"tty", &fakedev, -1, 0, 0, 0}, /* the Unix name for it */
{"stdin", &fakedev, 0, 0, 0, 0}, /* handle 0 (stdin) */
{"stdout", &fakedev, 1, 0, 0, 0}, /* handle 1 (stdout) */
{"stderr", &fakedev, 2, 0, 0, 0}, /* handle 2 (stderr) */
/* other miscellaneous devices */
{"mouse", &mouse_device, 0, 0, 0, 0},
{"null", &null_device, 0, 0, 0, 0},
#ifdef FASTTEXT
/* alternate console driver */
{"fasttext", &screen_device, 2, O_TTY, &con_tty, 0},
#endif
/* serial port things *must* come last, because not all of these
* are present on all machines (except for modem1, which does however
* have a different device number on TTs and STs)
*/
{"modem1", &bios_tdevice, 6, O_TTY, &aux_tty, 0},
{"modem2", &bios_tdevice, 7, O_TTY, &sccb_tty, 0},
{"serial1", &bios_tdevice, 8, O_TTY, &ttmfp_tty, 0},
{"serial2", &bios_tdevice, 9, O_TTY, &scca_tty, 0},
{"", 0, 0, 0, 0, 0}
};
struct bios_file *broot, *bdevlast;
/* a file pointer for BIOS device 1, provided only for insurance
* in case a Bconmap happens and we can't allocate a new FILEPTR;
* in most cases, we'll want to build a FILEPTR in the usual
* way.
*/
FILEPTR *defaultaux;
void
biosfs_init()
{
struct bios_file *b;
broot = BDEV;
for (b = broot; b->name[0]; b++) {
b->next = b+1;
/* if not a TT or Mega STE, adjust the MODEM1 device to be BIOS
* device 1
* and ignore the remaining devices, since they're not present
*/
if (!has_bconmap && b->private == 6) {
b->private = 1;
b->next = 0;
break;
}
/* SERIAL2 is not present on the Mega STe */
if (mch == MEGASTE && b->private == 8) {
b->next = 0;
break;
}
}
bdevlast = b;
if (b->name[0] == 0) {
--b;
b->next = 0;
}
defaultaux = new_fileptr();
defaultaux->links = 1; /* so it never gets freed */
defaultaux->flags = O_RDWR;
defaultaux->pos = 0;
defaultaux->devinfo = 0;
defaultaux->fc.fs = &bios_filesys;
defaultaux->fc.index = 0;
defaultaux->fc.aux = 1;
defaultaux->fc.dev = BIOSDRV;
defaultaux->dev = &bios_ndevice;
}
static long ARGS_ON_STACK
bios_root(drv, fc)
int drv;
fcookie *fc;
{
if (drv == BIOSDRV) {
fc->fs = &bios_filesys;
fc->dev = drv;
fc->index = 0L;
return 0;
}
fc->fs = 0;
return EINTRN;
}
static long ARGS_ON_STACK
bios_lookup(dir, name, fc)
fcookie *dir;
const char *name;
fcookie *fc;
{
struct bios_file *b;
if (dir->index != 0) {
DEB